home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / a86b.arc / PROC_LAB.DOC < prev    next >
Encoding:
Text File  |  1986-06-22  |  3.5 KB  |  80 lines

  1. ---PROC_LAB.DOC---
  2.  
  3. The PROC Directive
  4.  
  5. Syntax:  name  PROC NEAR
  6.          name  PROC FAR
  7.          name  PROC
  8.  
  9. PROC is a directive provided for compatibility with Intel/IBM assemblers.
  10. I don't like PROC; and I recommend that you do not use it, even if you are
  11. programming for those assemblers.
  12.  
  13. The idea behind PROC is to give the assembler a mechanism whereby it can
  14. decide for you what kind of RET instruction you should be providing.  If you
  15. specify NEAR in your PROC directive, then the assembler will generate a
  16. near (same segment) return when it sees RET.  If you specify FAR in your
  17. PROC directive, the assembler will generate a far RETF return (which will
  18. cause both IP and CS to be popped from the stack).  If you simply leave
  19. well enough alone, and never code a PROC in your program, then RET will
  20. mean near-return throughout your program.
  21.  
  22. The reason I don't like PROC is because it is yet another attempt by the
  23. assembler to do things "behind your back".  This goes against the reason why
  24. you are programming in assembly language in the first place, which is to
  25. have complete control over the code generated by your source program.  It
  26. leads to nothing but trouble and confusion.
  27.  
  28. Another problem with PROC is its verbosity.  It replaces a simple colon,
  29. given right after the label it defines.  This creates a visual clutter in the
  30. program, that makes the program harder to read.
  31.  
  32. Even if you are programming in that other assembler, and you need to code a
  33. far-return, I recommend that you create a RETF macro (it would have the single
  34. line DB 0CBH), and stay away from PROCs entirely.
  35.  
  36.  
  37. The ENDP Directive
  38.  
  39. Syntax:   [name] ENDP
  40.  
  41. The only action A86 takes when it sees an ENDP directive is to return the
  42. assembler to its (sane) default state, in which RET is a near-return.
  43.  
  44. NOTE that this means that A86 does not support nested PROCs, in which anything
  45. but the innermost PROC has the FAR attribute.  I'm sorry if I am blunt, but
  46. anybody who would subject their program to that level of syntactic clutter
  47. has rocks in their head.
  48.  
  49.  
  50. The LABEL Directive
  51.  
  52. Syntax:  name LABEL NEAR
  53.          name LABEL FAR
  54.          name LABEL BYTE
  55.          name LABEL WORD
  56.  
  57. LABEL is another directive provided for compatibility with Intel/IBM assemblers.
  58. A86 provides less verbose ways of specifying all the above LABEL forms, except
  59. for LABEL FAR.
  60.  
  61. LABEL defines "name" to have the type given, and a value equal to the current
  62. output pointer.  Thus, LABEL NEAR is synonomous with a simple colon following
  63. the name; and LABEL BYTE and LABEL WORD are synonymous with DB and DW,
  64. respectively, with no operands.
  65.  
  66. LABEL FAR does have a unique functionality, not found in other assemblers.  It
  67. identifies "name" as a procedure that can be called from outside this program's
  68. code segment.  Such procedures should have RETFs instead of RETs. Furthermore,
  69. I have provided the following feature, unique to A86: if you CALL the procedure
  70. from within your program, A86 will generate a PUSH CS instruction followed by a
  71. NEAR call to the procedure.  Other assemblers will generate a FAR call, having
  72. the same functional effect; but the FAR call consumes more program space, and
  73. takes more time to execute.
  74.  
  75. WARNING: you cannot use the above CALL feature as a forward-reference; the
  76. LABEL FAR definition must precede any CALLs to it.  This is unavoidable, since
  77. the assembler must assume that a CALL to an undefined symbol takes 3 program
  78. bytes.  All assemblers will issue an error in this situation.
  79.  
  80.